package com.sihai.ehr.service.impl;

import com.sihai.core.DataAccessor;
import com.sihai.core.Limit;
import com.sihai.core.LimitedList;
import com.sihai.core.Sorter;
import com.sihai.ehr.model.biz.WorkNo;
import com.sihai.ehr.service.WorkNoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author: wxn
 * @since: 12-6-18 下午11:23
 */
@Service("workNoService")
public class WorkNoServiceImpl implements WorkNoService {
    @Resource
    private DataAccessor dataAccessor;

    @Override
    public WorkNo get(Long id) {
        if(id == null){
            return null;
        }
        return dataAccessor.get(WorkNo.class, id);
    }

    @Override
    public LimitedList<WorkNo> findByOrganization(Long organizationId, Limit limit, Sorter sorter) {
        if(organizationId == null){
            return null;
        }
         
        return dataAccessor.findByHql(WorkNo.class, "from WorkNo w where w.organization <> null and w.organization.id = ?", new Object[]{organizationId}, limit, sorter);
    }

    @Override
    public void save(WorkNo workNo) {
        if(workNo == null){
            return;
        }
        dataAccessor.save(workNo);
    }
}
